package com.cin.cma.client.config;

import cn.hutool.core.codec.Base64;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

public class PrivateKeyConfig {
    private static final String PRIVATE_KEY = "Bn7tuc8MsZ9LbwkFrbQEHA==";

    /**
     * 解密
     *
     * @param content 解密内容
     * @return 解密后字符串
     */
    public static String decrypt(String content) {
        byte[] key = Base64.decode(PRIVATE_KEY);
        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
        byte[] encryptByte = Base64.decode(content);
        byte[] decrypt = aes.decrypt(encryptByte);
        return new String(decrypt);
    }

    /**
     * 加密
     *
     * @param content 加密内容
     * @return 加密后字符串
     */
    public static String encrypt(String content) {
        byte[] key = Base64.decode(PRIVATE_KEY);
        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
        //加密
        byte[] encrypt = aes.encrypt(content);
        return Base64.encode(encrypt);
    }
}
